﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Booking_Hotel.DBML;

namespace Booking_Hotel.DAL
{
    public class Supplier_LoaiPhongDAO
    {
        ThanhBHotelDataContext sdb = new ThanhBHotelDataContext();

        public Supplier_Hotel_LoaiPhong GetSupplier_Hotel_LoaiPhongByID(int ID)
        {
            return sdb.sp_Supplier_Hotel_LoaiPhong_Select(ID).SingleOrDefault();
        }

        public void addSupplier_Hotel_LoaiPhong(Supplier_Hotel_LoaiPhong shl)
        {
            Supplier_Hotel_LoaiPhong add = new Supplier_Hotel_LoaiPhong
            {
                Supplier_HotelID = shl.Supplier_HotelID,
                TenLoaiPhong = shl.TenLoaiPhong,
                GiaPhong=shl.GiaPhong,
                Description = shl.Description,
                TrangThaiLoaiPhong = shl.TrangThaiLoaiPhong

            };
            sdb.Supplier_Hotel_LoaiPhongs.InsertOnSubmit(add);
            sdb.SubmitChanges();
        }

        public void updateSupplier_Hotel_LoaiPhong(Supplier_Hotel_LoaiPhong shl)
        {
            Supplier_Hotel_LoaiPhong update = sdb.Supplier_Hotel_LoaiPhongs.Single(ca => ca.Supplier_Hotel_LoaiPhongID == (int)shl.Supplier_Hotel_LoaiPhongID);
            {
                update.Supplier_Hotel_LoaiPhongID = shl.Supplier_Hotel_LoaiPhongID;
                update.Supplier_HotelID = shl.Supplier_HotelID;
                update.TenLoaiPhong = shl.TenLoaiPhong;
                update.GiaPhong = shl.GiaPhong;
                update.Description = shl.Description;
                update.TrangThaiLoaiPhong = shl.TrangThaiLoaiPhong;
            }
            sdb.SubmitChanges();
        }
    }
}